<include file="Common/header" />
<!-- 导航栏 -->
{$bread_crumb}
<!-- 导航栏 -->
<div class="page-container">
    <!-- 搜索 -->
    <!-- 操作 -->
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="r">共有数据：<strong>{$count}</strong> 条</span> 
    </div>
    <div class="mt-20 dataTables_wrapper">
    <table class="table table-border table-bordered table-hover table-bg table-sort">
        <thead>
            <tr class="text-c">
                <th>编号</th>
                <th>平台唯一值</th>
                <th>快递平台</th>
                <th width="280">描述</th>
                <th>是否开启</th>
                <th>是否默认</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <foreach name="datas" item="item">
                <tr class="text-c">
                    <td>{$item['id']}</td>
                    <td>{$item['key']}</td>
                    <td>{$item['name']}</td>
                    <td>{$item['description']}</td>
                    <td>
                        <if condition="$item['is_open'] eq 1">
                        <span class="badge badge-success radius">已开启</span>
                        <else />
                        <span class="badge badge-danger radius">关闭</span>
                        </if>
                    </td>
                    <td>
                        <if condition="$item['is_default'] eq 1">
                        <span class="badge badge-success radius">默认选择</span>
                        <else />
                        <span class="badge badge-danger radius">否</span>
                        </if>
                    </td>
                    <td class="td-manage">
                        <a style="text-decoration:none" class="ml-5" onClick="update('修改配置信息','{:U(CONTROLLER_NAME.'/update')}','{$item['id']}')" href="javascript:;" title="修改配置信息"><i class="Hui-iconfont">&#xe6df;</i></a>
                    </td>
                </tr>
            </foreach>
        </tbody>
    </table>
    {$pages}
</div>
<include file="Common/footer" />
<script type="text/javascript">
/*添加*/
function add(title,url){
    var index = layer.open({
        type: 2,
        title: title,
        content: url,
        end:function () {
            window.location.reload();
        }
    });
    layer.full(index);
}
/*编辑*/
function update(title,url,id){
    var index = layer.open({
        type: 2,
        title: title,
        content: url + '?id=' + id,
        end:function () {
            window.location.reload();
        }
    });
    layer.full(index);
}
/*删除*/
function del(obj,id){
    layer.confirm('确认要删除吗？',function(index){
        $.ajax({
            type: 'POST',
            url: '{:U(CONTROLLER_NAME.'/delete')}',
            data: {id: id},
            dataType: 'json',
            success: function(data){
                if (data.code == 0) {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                } else {
                    layer.msg(data.msg,{icon:2,time:1000});
                }
            },
            error: function(data) {
                console.log(data.msg);
            },
        });     
    });
}
/*删除所选*/
function del_select() {
    var arr = []
        ids = '';
    $('.select:checkbox:checked').each(function() {
        arr.push($(this).val());
    });

    ids = arr.join(',');
    layer.confirm('确认要删除吗？',function(index){
        $.ajax({
            type: 'POST',
            url: '{:U(CONTROLLER_NAME.'/delete')}',
            data: {id: ids},
            dataType: 'json',
            success: function(data){
                if (data.code == 0) {
                    layer.msg('已删除!',{icon:1,time:1000});
                    window.location.reload();
                } else {
                    layer.msg(data.msg,{icon:2,time:1000});
                }
            },
            error: function(data) {
                console.log(data.msg);
            },
        });
    });
}
</script> 